package com.dmpp.mes.service.impl;


import com.dmpp.mes.bean.ResponseData;
import com.dmpp.mes.dao.DeviceCategoryMapper;
import com.dmpp.mes.parameterInfo.DeviceCategory;
import com.dmpp.mes.service.DeviceCategoryService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service(value = "DeviceCategoryService")

public class DeviceCategoryServiceImpl implements DeviceCategoryService {

    @Autowired
    private DeviceCategoryMapper mapper;

    @Override
    public ResponseData findAll() {
        ResponseData responseData = new ResponseData();
        PageInfo pageInfo = new PageInfo<>(mapper.findAll());
        responseData.setData(pageInfo);
        return responseData;
    }

    @Override
    public ResponseData findByCategory(String category) {
        ResponseData responseData = new ResponseData();
        responseData.setData(mapper.findByCategory(category));
        return responseData;
    }

    @Override
    public ResponseData insert(DeviceCategory deviceCategory) {
        ResponseData responseData = new ResponseData();
        mapper.insert(deviceCategory);
        return responseData;
    }

    @Override
    public ResponseData updateById(DeviceCategory deviceCategory) {
        ResponseData responseData = new ResponseData();
        mapper.updateById(deviceCategory);
        return responseData;
    }

    @Override
    public ResponseData delete(String category) {
        ResponseData responseData = new ResponseData();
        mapper.delete(category);
        return responseData;
    }
}
